package com.genesis.yunnanji.utils;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.Window;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.genesis.yunnanji.R;


public class LoadingDialog extends Dialog {

    public LoadingDialog(Context context, int theme) {
        super(context, theme);
        init();
    }

    public LoadingDialog(Context context) {
        super(context);
        init();
    }

    TextView tv;
    ProgressBar pb;

    private void init() {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        setContentView(R.layout.dialog_loading);
        setCanceledOnTouchOutside(false);
        tv = (TextView) findViewById(R.id.tv_loading);
        pb = (ProgressBar) findViewById(R.id.pb_loading);
    }

    /**
     * 设置提醒文字
     *
     * @param text
     */
    public void setText(String text) {
        tv.setText(text);
    }

    /**
     * 设置显示Progress
     */
    public void showProgressBar(boolean show) {
        if (show) {
            pb.setVisibility(View.VISIBLE);
        } else {
            pb.setVisibility(View.GONE);
        }
    }

    /**
     * 是否显示文字
     *
     * @param show
     */
    public void showTextView(boolean show) {
        if (show) {
            tv.setVisibility(View.VISIBLE);
        } else {
            tv.setVisibility(View.GONE);
        }
    }
}
